using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public abstract class State
{
    protected StateMachine stateMachine;
    protected EntityBase entity;
    protected string animName;
    protected Rigidbody2D rb;
    protected float xInput;
    protected float yInput;
    protected bool triggerCalled;
    protected float stateTimer;

    public State(EntityBase entity, StateMachine stateMachine, string animName)
    {
        this.stateMachine = stateMachine;
        this.entity = entity;
        this.animName = animName;

    }

    public virtual void Enter()
    {
        this.rb = entity.rb;
        entity.anim.SetBool(animName, true);
        triggerCalled = false;
    }

    public virtual void Update()
    {
        stateTimer -= Time.deltaTime;
        if (entity is Player)
        {
            xInput = Input.GetAxisRaw("Horizontal");
            yInput = Input.GetAxisRaw("Vertical");
            entity.anim.SetFloat("yVelocity", rb.velocity.y);
        }
        
    }

    public virtual void Exit()
    {
        entity.anim.SetBool(animName, false);
    }

    internal virtual void AnimationFinishTrigger()
    {
        triggerCalled = true;
    }
}
